package com.bsj.media.init;

import com.bsj.media.tool.HttpPlayBackTool;
import com.bsj.media.tool.HttpPlayVideoTool;
import com.bsj.power.common.config.cached.RedisCached;
import com.bsj.power.common.config.redis.RedisConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author yinhao
 * @version 1.0
 * @description 重置设备视频链路
 * @date 2024/8/5
 */
@Component
@Slf4j
public class RestActionUtil {

    @Autowired
    private RedisCached redisCached;

    public void reset() {
        HttpPlayVideoTool.init();
        HttpPlayBackTool.init();
        Map<String, String> map = redisCached.hgetAll(RedisConstant.VIDEO_PLAY_STATUS);
        map.forEach((key, value) -> {
            String[] split = key.split("-");
            HttpPlayVideoTool.liveCloseCmd(split[0], Integer.parseInt(value), true);
        });
        redisCached.del(RedisConstant.VIDEO_PLAY_STATUS);
        log.info("重置多媒体信息数： {} ", map.size());
    }
}
